package com.cncytech.uiautomator_demo.page;

import androidx.test.uiautomator.By;
import androidx.test.uiautomator.UiDevice;
import androidx.test.uiautomator.UiObject;
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.UiSelector;

import java.util.Objects;

public class MainPage {

    private UiDevice device;

    public MainPage(UiDevice device) {
        this.device = device;
    }

    public MainPage authorization() {
        String strs[]  = new String[]{"使用期间允许","本次使用允许","仅在使用该应用时允许","允许"};
        for (String str : strs){
            UiObject2 object = device.findObject(By.textContains(str).clickable(true));
            while (Objects.nonNull(object)) {
                    if (object.isClickable()) {
                        object.click();
                    }
                object  = device.findObject(By.textContains(str).clickable(true));
            }
        }
        return this;
    }
}